<?php
	echo "
	<script language='javascript'>
		function generateHtmlField(number) {
			content = '<div id=\"field'+number+'\" style=\"border:solid 1px; padding:10px; margin:10px;\">'+
					  '<div class=\"input\">'+
					  '<label for=\"Fctemplate_'+number+'Name\">Nome do campo</label>'+
					  '<input name=\"data[Fctemplate_'+number+'][name]\" type=\"text\" value=\"\" id=\"Fctemplate_'+number+'Name\" /><br/>'+
					  '</div>'+
					  '<label for=\"Fctemplate_'+number+'Type\">Tipo do campo</label>'+
					  '<select name=\"data[Fctemplate_'+number+'][type]\" id=\"Fctemplate_'+number+'Type\">'+
					  '<option value=\"\">Selecione um tipo</option>'+
					  '<option value=\"string\">Texto</option>'+
					  '<option value=\"texto\">Texto grande</option>'+
					  '<option value=\"inteiro\">Numero</option>'+
					  '<option value=\"data\">Data</option>'+
					  '<option value=\"file\">Arquivo</option>'+
					  '</select><br/>'+
					  '<div class=\"input\">'+
					  '<label for=\"Fctemplate_'+number+'Descricao\">Descrição do campo</label>'+
					  '<input name=\"data[Fctemplate_'+number+'][description]\" type=\"text\" value=\"\" id=\"Fctemplate_'+number+'Description\" /><br/>'+
					  '</div>'+
					  '<div class=\"input\">'+
					  '<label for=\"Fctemplate_'+number+'Help\">Texto de ajuda</label>'+
 					  '<input name=\"data[Fctemplate_'+number+'][help]\" type=\"text\" value=\"\" id=\"Fcampo_'+number+'Ajuda\" /><br/>'+
 					  '</div>'+
 					  '<span><a href=\"javascript:void(0);\" onClick=\"removeField('+number+')\">Remover campo</a></span>'+
					  '</div>';
			return content;
		}
	
		function addNewField(number) {
			next = parseInt(number) + 1;
			content = '<div>'+generateHtmlField(number)+'</div><div id=newField'+next+'></div>'
			document.getElementById('newField'+number).innerHTML = content;
			document.getElementById('FtemplateFieldIterator').value = next;
		}
		
		function removeField(number) {			
			document.getElementById('field'+number).innerHTML = '';
			document.getElementById('field'+number).style.display = 'none';
		}
	</script>
	"; 
	
	echo $accessibility->whereIAm($pageTitle,array(array('title'=>'Formulários - Modelos','link'=>'/ftemplates'),array('title'=>'Cadastrar modelo')));
	
	echo "<h2 id='contentTitle'>".$pageTitle."</h2>";
	echo $form->create();
	echo $form->input('name',array('label'=>'Nome'));
	echo $form->input('description',array('label'=>'Descrição'));
	echo "<br />";
	echo "<br />";
	
	
	echo $form->hidden('fieldIterator', array('value'=>0));
	echo "<div id='newField0'></div>";
	echo "<br />"; 
	echo $html->link('Novo campo','javascript:void(0);', array('onClick'=>'addNewField(document.getElementById(\'FtemplateFieldIterator\').value);'));
	echo "<br />"; 
	echo "<br />"; 
	echo $form->end('Cadastrar modelo');
		